home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 22 / PC Actual CD 22.iso / SHARE / prog / POVRAY / BOOKS.ZIP / Books.inc next >
Encoding:
Text File  |  1997-04-21  |  9.4 KB  |  266 lines

  1. // Persistence of Vision Ray Tracer Scene Description File
  2. // File: Books.inc
  3. // Vers: 3.01 Watcom Win32
  4. // Desc: A file for the creation of rows or stacks of books
  5. // Date: April 18, 1997
  6. // Auth: Sonya Roberts
  7. // Note: Creates simple books shapes that are meant to be
  8. //       seen from a distance, not closeup; the books are
  9. //       only minimally detailed.
  10.  
  11. #ifndef (RowLength)    #declare RowLength=2        #end    // How long a row of books to create (X-Axis)
  12. #ifndef (RowHeight)    #declare RowHeight=.75        #end    // How tall a row of books to create (Y-Axis)
  13. #ifndef (RowDepth)    #declare RowDepth=.5        #end    // How deep a row of books to create (Z-Axis)
  14. #ifndef (NumBooks)    #declare NumBooks=10        #end    // Approximate number of books in the row
  15. #ifndef (VariThick)    #declare VariThick=.1        #end    // Decimal Percentage by which thickness of books are to vary.
  16. #ifndef (VariHeight)    #declare VariHeight=.05        #end    // Decimal Percenatge by which height of books are to vary.
  17. #ifndef (VariDepth)    #declare VariDepth=.05        #end    // Decimal Percentage by which depth of books are to vary.
  18. #ifndef (BookSeed)    #declare BookSeed=seed(1)    #end    // Seed value to use for random numbers
  19. #ifndef (VariColours)    #declare VariColours=True    #end    // If true, colours of bindings are random; otherwise uses a supplied texture
  20. #ifndef (VariAlign)    #declare VariAlign=.1        #end    // Decimal Percentage of RowDepth by which spines of books are to misaligned
  21. #ifndef (StackStyle)    #declare StackStyle=0        #end    // 0=Shelved (Bottom Edges Even), 1=Nicely Stacked, 2=Messily Stacked
  22. #ifndef (FillerColour)    #declare FillerColour=0        #end    // 0=Plain White, 1=Gray Gradient
  23. #ifndef (ExactLength)    #declare ExactLength=True    #end    // 0=NumBooks More Important Than RowLength, 1=Vice Versa
  24. #ifndef (Titles)    #declare Titles=False        #end    // 0=Plain Covers, 1=Titles on Spines
  25.  
  26. #if (VariColours=False)
  27.     #declare Bindings=rgb <.35+(rand(BookSeed)*.5),.35+(rand(BookSeed)*.5),.35+(rand(BookSeed)*.5)>
  28. #end
  29.  
  30. #declare TSeed=seed(1000+int(rand(BookSeed)*1000))
  31.  
  32. #declare X1=1
  33. #declare LengthSoFar=0
  34. #declare SmallestRemainder=RowLength-((LengthSoFar/NumBooks)*(1+VariThick))
  35. #declare StandardWidth=RowLength/NumBooks
  36. union {
  37.     #while (LengthSoFar<SmallestRemainder)
  38.         #declare BookWidth=StandardWidth+(StandardWidth*((rand(BookSeed)*(VariThick*2))-VariThick))
  39.         #declare BookHeight=RowHeight-(RowHeight*(rand(BookSeed)*VariHeight))
  40.         #declare BookDepth=RowDepth-(RowDepth*(rand(BookSeed)*VariDepth))
  41.  
  42.         union {
  43.             difference {
  44.                 union {
  45.                     cylinder {<0,0,0>,<0,BookHeight,0>,BookWidth/2    scale <1,1,.25>}
  46.                     box {<-BookWidth/2,0,0>,<BookWidth/2,BookHeight,BookDepth>}
  47.                 }
  48.                 union {
  49.                     cylinder {<0,0,0>,<0,BookHeight,0>,BookWidth/2    scale <1,1,.25>}
  50.                     box {<-BookWidth/2,0,0>,<BookWidth/2,BookHeight,BookDepth>}
  51.                     scale <.9,1.1,1>
  52.                     translate <0,-BookHeight*.05,BookDepth*.1>
  53.                 }
  54.                 #if (VariColours=True)
  55.                     #declare Bindings=rgb <.35+(rand(BookSeed)*.5),.35+(rand(BookSeed)*.5),.35+(rand(BookSeed)*.5)>
  56.                 #end
  57.                 pigment {color Bindings}
  58.             }
  59.             #if (Titles=True)
  60.                 #include "titles.inc"
  61.                 
  62.                 #declare TextColor=int(rand(BookSeed)*3.9)
  63.                 text {
  64.                     ttf "timrom.ttf"
  65.                     BookTitle
  66.                     .1,0
  67.                     translate <0,-.25,0>
  68.                     scale <BookHeight/9,BookHeight/9,1>
  69.                     rotate z*-90
  70.                     translate <0,BookHeight*.95,-BookWidth/8>
  71.                     #switch (TextColor)
  72.                         case (0)
  73.                             pigment {color Bindings*2}
  74.                         #break
  75.                         case (0)
  76.                             pigment {color White-Bindings}
  77.                         #break
  78.                         case (2)    pigment {color Black}    #break
  79.                         case (3)    pigment {color White}    #break
  80.                     #end
  81.                 }
  82.             #end
  83.             box {
  84.                 <-(BookWidth/2),BookHeight*.025,0>,<BookWidth/2,BookHeight-(BookHeight*.025),BookDepth*.975>
  85.                 scale <.9,1,1>
  86.                 #switch (FillerColour)
  87.                     #case (0)    // Default Plain White
  88.                         pigment {color White}
  89.                         finish {ambient .3}
  90.                     #break
  91.  
  92.                     #case (1)    // Gray Gradient
  93.                         texture {
  94.                             pigment {
  95.                                 gradient x
  96.                                 turbulence 0.01
  97.                                 color_map {
  98.                                     [0.00 color rgb<1.000, 1.000, 1.000>]
  99.                                     [0.05 color rgb<0.753, 0.753, 0.753>]
  100.                                     [0.05 color rgb<0.918, 0.918, 0.918>]
  101.                                     [0.09 color rgb<0.718, 0.718, 0.718>]
  102.                                     [0.15 color rgb<0.816, 0.816, 0.816>]
  103.                                     [0.21 color rgb<0.918, 0.918, 0.918>]
  104.                                     [0.25 color rgb<0.784, 0.784, 0.784>]
  105.                                     [0.28 color rgb<0.980, 0.980, 0.980>]
  106.                                     [0.36 color rgb<0.710, 0.710, 0.710>]
  107.                                     [0.42 color rgb<0.867, 0.867, 0.867>]
  108.                                     [0.47 color rgb<0.933, 0.933, 0.933>]
  109.                                     [0.59 color rgb<0.675, 0.675, 0.675>]
  110.                                     [0.68 color rgb<1.000, 1.000, 1.000>]
  111.                                     [0.75 color rgb<0.776, 0.776, 0.776>]
  112.                                     [0.84 color rgb<0.878, 0.878, 0.878>]
  113.                                     [0.92 color rgb<1.000, 1.000, 1.000>]
  114.                                     [0.95 color rgb<0.784, 0.784, 0.784>]
  115.                                     [1.00 color rgb<1.000, 1.000, 1.000>]
  116.                                 }
  117.                             }
  118.                             finish {
  119.                                 ambient 0.5
  120.                                 brilliance 1.5
  121.                             }
  122.                             scale <BookWidth,1,1>
  123.                             translate <rand(BookSeed)*RowLength,0,0>
  124.                         }
  125.                     #break
  126.                 #end
  127.             }
  128.  
  129.             #switch (StackStyle)
  130.                 #case (0)    // Shelved (Bottom Edges Level, runs in the positive X direction)
  131.                     translate <LengthSoFar+(BookWidth/2),0,-(rand(BookSeed)*(BookDepth*VariAlign))>
  132.                 #break
  133.  
  134.                 #case (1)    // Nicely Stacked (Varies slightly back and forth, and is vertical)
  135.                     rotate z*90
  136.                     translate <BookHeight/2,0,-BookDepth/2>
  137.                     translate <rand(BookSeed)*(BookHeight/10),LengthSoFar+(BookWidth/2),rand(BookSeed)*(BookDepth/10)>
  138.                     rotate y*((rand(BookSeed)*20)-10)
  139.                 #break
  140.  
  141.                 #case (2)    // Messily Stacked (Piled Up Any Which Way, also vertical)
  142.                     rotate z*90
  143.                     translate <BookHeight/2,LengthSoFar+(BookWidth/2),-BookDepth/2>
  144.                     rotate y*(rand(BookSeed)*360)
  145.                 #break
  146.             #end
  147.         }
  148.         #declare X1=X1+1
  149.         #declare LengthSoFar=LengthSoFar+BookWidth
  150.     #end
  151.  
  152.     #if (LengthSoFar<RowLength & ExactLength=True)
  153.         #declare BookWidth=RowLength-LengthSoFar
  154.         #declare BookHeight=RowHeight-(RowHeight*(rand(BookSeed)*VariHeight))
  155.         #declare BookDepth=RowDepth-(RowDepth*(rand(BookSeed)*VariDepth))
  156.  
  157.         union {
  158.             difference {
  159.                 union {
  160.                     cylinder {<0,0,0>,<0,BookHeight,0>,BookWidth/2    scale <1,1,.25>}
  161.                     box {<-BookWidth/2,0,0>,<BookWidth/2,BookHeight,BookDepth>}
  162.                 }
  163.                 union {
  164.                     cylinder {<0,0,0>,<0,BookHeight,0>,BookWidth/2    scale <1,1,.25>}
  165.                     box {<-BookWidth/2,0,0>,<BookWidth/2,BookHeight,BookDepth>}
  166.                     scale <.9,1.1,1>
  167.                     translate <0,-BookHeight*.05,BookDepth*.1>
  168.                 }
  169.                 #if (VariColours=True)
  170.                     #declare Bindings=rgb <.35+(rand(BookSeed)*.5),.35+(rand(BookSeed)*.5),.35+(rand(BookSeed)*.5)>
  171.                 #end
  172.                 pigment {color Bindings}
  173.             }
  174.             #if (Titles=True)
  175.                 #include "titles.inc"
  176.                 
  177.                 #declare TextColor=int(rand(BookSeed)*3.9)
  178.                 text {
  179.                     ttf "timrom.ttf"
  180.                     BookTitle
  181.                     .1,0
  182.                     translate <0,-.25,0>
  183.                     scale <BookHeight/9,BookHeight/9,1>
  184.                     rotate z*-90
  185.                     translate <0,BookHeight*.95,-BookWidth/8>
  186.                     #switch (TextColor)
  187.                         case (0)
  188.                             pigment {color (Bindings*2)}
  189.                         #break
  190.                         case (0)
  191.                             pigment {color (White-Bindings)}
  192.                         #break
  193.                         case (2)    pigment {color Black}    #break
  194.                         case (3)    pigment {color White}    #break
  195.                     #end
  196.                 }
  197.             #end
  198.             box {
  199.                 <-(BookWidth/2),BookHeight*.025,0>,<BookWidth/2,BookHeight-(BookHeight*.025),BookDepth*.975>
  200.                 scale <.9,1,1>
  201.                 #switch (FillerColour)
  202.                     #case (0)    // Default Plain White
  203.                         pigment {color White}
  204.                         finish {ambient .3}
  205.                     #break
  206.  
  207.                     #case (1)    // Gray Gradient
  208.                         texture {
  209.                             pigment {
  210.                                 gradient x
  211.                                 turbulence 0.01
  212.                                 color_map {
  213.                                     [0.00 color rgb<1.000, 1.000, 1.000>]
  214.                                     [0.05 color rgb<0.753, 0.753, 0.753>]
  215.                                     [0.05 color rgb<0.918, 0.918, 0.918>]
  216.                                     [0.09 color rgb<0.718, 0.718, 0.718>]
  217.                                     [0.15 color rgb<0.816, 0.816, 0.816>]
  218.                                     [0.21 color rgb<0.918, 0.918, 0.918>]
  219.                                     [0.25 color rgb<0.784, 0.784, 0.784>]
  220.                                     [0.28 color rgb<0.980, 0.980, 0.980>]
  221.                                     [0.36 color rgb<0.710, 0.710, 0.710>]
  222.                                     [0.42 color rgb<0.867, 0.867, 0.867>]
  223.                                     [0.47 color rgb<0.933, 0.933, 0.933>]
  224.                                     [0.59 color rgb<0.675, 0.675, 0.675>]
  225.                                     [0.68 color rgb<1.000, 1.000, 1.000>]
  226.                                     [0.75 color rgb<0.776, 0.776, 0.776>]
  227.                                     [0.84 color rgb<0.878, 0.878, 0.878>]
  228.                                     [0.92 color rgb<1.000, 1.000, 1.000>]
  229.                                     [0.95 color rgb<0.784, 0.784, 0.784>]
  230.                                     [1.00 color rgb<1.000, 1.000, 1.000>]
  231.                                 }
  232.                             }
  233.                             finish {
  234.                                 ambient 0.5
  235.                                 brilliance 1.5
  236.                             }
  237.                             scale <BookWidth,1,1>
  238.                             translate <rand(BookSeed)*RowLength,0,0>
  239.                         }
  240.                     #break
  241.                 #end
  242.             }
  243.  
  244.             #switch (StackStyle)
  245.                 #case (0)    // Shelved (Bottom Edges Level, runs in the positive X direction)
  246.                     translate <LengthSoFar+(BookWidth/2),0,-(rand(BookSeed)*(BookDepth*VariAlign))>
  247.                 #break
  248.  
  249.                 #case (1)    // Nicely Stacked (Varies slightly back and forth, and is vertical)
  250.                     rotate z*90
  251.                     translate <BookHeight/2,0,-BookDepth/2>
  252.                     translate <rand(BookSeed)*(BookHeight/10),LengthSoFar+(BookWidth/2),rand(BookSeed)*(BookDepth/10)>
  253.                     rotate y*((rand(BookSeed)*20)-10)
  254.                 #break
  255.  
  256.                 #case (2)    // Messily Stacked (Piled Up Any Which Way, also vertical)
  257.                     rotate z*90
  258.                     translate <BookHeight/2,LengthSoFar+(BookWidth/2),-BookDepth/2>
  259.                     rotate y*(rand(BookSeed)*360)
  260.                 #break
  261.             #end
  262.         }
  263.         #declare LengthSoFar=LengthSoFar+BookWidth
  264.     #end
  265. }
  266.